﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.U2D;

namespace Kylin
{
	public class AtlasLoader : SingletonMonobehaviour<AtlasLoader>
	{
        void OnEnable()
        {
            SpriteAtlasManager.atlasRequested += RequestAtlas;
        }

        void OnDisable()
        {
            SpriteAtlasManager.atlasRequested -= RequestAtlas;
        }


        void RequestAtlas(string tag, System.Action<SpriteAtlas> callback)
        {
            Debug.Log("tag = " + tag);
            string shortPath = "Atlas/" + tag;
            UnityEngine.Object o = ResourceLoader.LoadAsset(shortPath);
            //var sa = Resources.Load<SpriteAtlas>(tag);
            callback(o as SpriteAtlas);
        }
    }
}


